package archer.application.core.entity.system;

import archer.framework.common.entity.BaseEntity;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * @author christ
 * @date 2016/6/7
 */
@Entity
public class RoleMenuRel extends BaseEntity {

    public static final Find<RoleMenuRel> find = new Find<>(RoleMenuRel.class);

    //--------------------------
    //  relations
    //--------------------------
    @ManyToOne
    @JoinColumn(name = "menu_id")
    private Menu menu;

    @ManyToOne
    @JoinColumn(name = "role_id")
    private Role role;

    //--------------------------
    //  getter setter
    //--------------------------

    public Menu getMenu() {
        return menu;
    }

    public RoleMenuRel setMenu(Menu menu) {
        this.menu = menu;
        return this;
    }

    public Role getRole() {
        return role;
    }

    public RoleMenuRel setRole(Role role) {
        this.role = role;
        return this;
    }

    public String getMenuId() {
        if (this.menu == null) {
            this.menu = new Menu();
        }
        return this.menu.getId();
    }

    public RoleMenuRel setMenuId(String menuId) {
        if (this.menu == null) {
            this.menu = new Menu();
        }
        this.menu.setId(menuId);
        return this;
    }

    public String getRoleId() {
        if (this.role == null) {
            this.role = new Role();
        }
        return this.role.getId();
    }

    public RoleMenuRel setRoleId(String roleId) {
        if (this.role == null) {
            this.role = new Role();
        }
        this.role.setId(roleId);
        return this;
    }

}
